package net.alegen.android.pizzashop.ui.order;

import net.alegen.android.pizzashop.R;
import net.alegen.android.pizzashop.order.CheeseEnum;
import net.alegen.android.pizzashop.order.Order;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.RadioButton;
import android.widget.RadioGroup;

public class ShapeLayoutFragment extends Fragment implements OnClickListener {
	
	private RadioButton radBtnCircle;
	private RadioButton radBtnSquare;
	private RadioButton radBtnTriangle;

	@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    	View v = inflater.inflate(R.layout.pizza_shape_layout, null);
    	RadioGroup radioGroupShapes = (RadioGroup)v.findViewById(R.id.radioGroupShapes);
    	radioGroupShapes.check(R.id.radBtnCircle);
    	
    	this.radBtnCircle = (RadioButton)v.findViewById(R.id.radBtnCircle);
    	this.radBtnSquare = (RadioButton)v.findViewById(R.id.radBtnSquare);
    	this.radBtnTriangle = (RadioButton)v.findViewById(R.id.radBtnTriangle);
    	
    	this.radBtnCircle.setOnClickListener(this);
    	this.radBtnSquare.setOnClickListener(this);
    	this.radBtnTriangle.setOnClickListener(this);
    	
        return v;
    }

	public void onClick(View v) {
		if(v == this.radBtnCircle)
			Order.cheese = CheeseEnum.NONE;
		else if(v == this.radBtnSquare)
			Order.cheese = CheeseEnum.MEDIUM;
		else if(v == this.radBtnTriangle)
			Order.cheese = CheeseEnum.DOUBLE;
	}
}